import { View } from "../../../mvc/core/View";
import { IToolTipItem } from "../../../../com/mui/manager/IToolTipItem";
import { LayerManager } from "../../manager/LayerManager";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { Cache } from "../../cache/Cache";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GameController } from "../../mvc/GameController";
import { STestVIPCard } from "../../../../Message/Game/STestVIPCard";
import { ClockManager } from "../../manager/ClockManager";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { StaticResUrl } from "../../resource/StaticResUrl";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { ColorConfig } from "../../resource/ColorConfig";
//class VipCard
    
    export  class VipCard extends View implements IToolTipItem
    {
        constructor()
        {
            super();
            layer = LayerManager.rightTopUILayer;
            buttonMode = true;
            addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            return;
        }

        /* internal  */onVipCardImgLoaded(arg1: ImageInfo): void
        {
            if (arg1 && arg1.bitmapData) 
            {
                if (!this._bmp) 
                {
                    this._bmp = new Object /* flash.display.Bitmap */();
                }
                this._bmp.x = 15;
                this._bmp.y = 15;
                this._bmp.bitmapData = arg1.bitmapData;
                this._bmp.width = 32;
                this._bmp.height = 32;
                addChild(this._bmp);
            }
            return;
        }

        /* internal  */onTestCardTimeOut(): void
        {
            hide();
            Cache.instance.vip.vipTestCard = null;
            this.clean();
            Dispatcher.dispatchEvent(new DataEvent(EventName.Guide_VIPTestEnd));
            return;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            GameController.vip.view.show();
            return;
        }

        public updateData(arg1: Object /* flash.display.Bitmap */): void
        {
            this.clearBmp();
            this._bmp = arg1;
            addChild(this._bmp);
            this._bmp.x = 15;
            this._bmp.y = 15;
            this._bmp.width = 32;
            this._bmp.height = 32;
            return;
        }

        public updateInfo(arg1: STestVIPCard): void
        {
            this._card = arg1;
            var loc1=new Date(ClockManager.instance.nowDate.time + (this._card.leftTime + 2) * 1000);
            ClockManager.instance.addDateCall(loc1, this.onTestCardTimeOut);
            LoaderManager.instance.load(StaticResUrl.VipTestCard, this.onVipCardImgLoaded);
            ToolTipsManager.register(this);
            this.toolTipData = HTMLUtil.addColor(Language.getString(41286), ColorConfig.instance.getItemColor(3).color);
            return;
        }

        public clearBmp(): void
        {
            if (this._bmp != null) 
            {
                if (this._bmp.parent) 
                {
                    removeChild(this._bmp);
                }
                this._bmp = null;
            }
            return;
        }

        public clean(): void
        {
            this.clearBmp();
            this._card = null;
            ToolTipsManager.unregister(this);
            return;
        }

        public get toolTipData()
        {
            return this._tooltipData;
        }

        public set toolTipData(arg1)
        {
            this._tooltipData = arg1;
            return;
        }

        /* internal */ /* var */_bmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_card: STestVIPCard;

        /* internal */ /* var */_tooltipData;
    }
